package com.yangguang.huahui.ui.activitys;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.hyphenate.EMCallBack;
import com.hyphenate.chat.EMClient;
import com.yangguang.huahui.R;
import com.yangguang.huahui.entity.DataInfo;
import com.yangguang.huahui.utils.SharedPreferenceUtil;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/3/29.
 */

public class SettingActivity extends BaseActivity{
    @BindView(R.id.tv_title)
    TextView tv_title;

    @OnClick({R.id.iv_back, R.id.btn_logout})
    void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.btn_logout:
                logout();
                break;
        }
    }
    @Override
    protected int initLayoutId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initView() {
        tv_title.setText(getString(R.string.setting));
    }

    @Override
    protected void initData() {

    }

    private void logout(){
        SharedPreferenceUtil.getInstance(mContext).delete();
        EMClient.getInstance().logout(true, new EMCallBack() {
            @Override
            public void onSuccess() {
                DataInfo.TOKEN = "";
                DataInfo.LOGOUT = "logout";
                startActivity(new Intent(mContext, MainActivity.class));
//                finish();
            }

            @Override
            public void onError(int i, String s) {

            }

            @Override
            public void onProgress(int i, String s) {

            }
        });
    }
}
